import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Card
import androidx.compose.material3.CardDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import com.test.platform.model.XTSReport

@Composable
fun XTSReportItem(report: XTSReport) {
    Card(
        modifier = Modifier
            .fillMaxWidth()
            .padding(8.dp),
        elevation = CardDefaults.cardElevation(4.dp)
    ) {
        Column(
            modifier = Modifier.padding(16.dp)
        ) {
            Text(text = "${report.owner}/${report.name}", style = MaterialTheme.typography.titleMedium)
            Text(text = "迭代版本: ${report.iterationVersion}")
            Text(text = "API版本: ${report.apiVersion}")
            Text(
                text = "运行结果: ${report.runningResult}",
                color = when(report.runningResult) {
                    "pass" -> Color.Green
                    "fail" -> Color.Red
                    else -> Color.Gray
                }
            )
            if (!report.failReason.isNullOrEmpty()) {
                Text(text = "失败原因: ${report.failReason}")
            }
        }
    }
}
